{include file='header'/}
<title>编辑内容</title>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layuimini-form" action="javascript:;" onsubmit="return dosub(this)" onkeydown="if(event.keyCode==13){return false;}" method="post">
            <!-- <div class="layui-form-item">
                <input type="hidden" name="type_id" id="type_id" value="{$type_id}">
                <label class="layui-form-label required">所属栏目</label>
                <div class="layui-input-block">
                    <select name="type_id">
                        {foreach $pidMenuList as $vo}
                        <option value="{$vo.id}" {if $vo.id==$data.type_id}selected=""{/if}>{$vo.cate_name|raw}</option>
                        {/foreach}
                    </select>
                </div>
            </div> -->
            <div class="layui-form-item">
                <label class="layui-form-label required">类型</label>
                <div class="layui-input-block">
                    <label>
                        <select name="type_content" lay-verify="required" lay-reqtext="请选择类型">
                            <option value="1" {if 1==$data.type_content}selected=""{/if}>政策原文</option>
                            <option value="2" {if 2==$data.type_content}selected=""{/if}>实施细则</option>
                        </select>
                    </label>
                </div>
            </div>
            <input type="hidden" name="type_md" id="type_md" value="2">
            <input type="hidden" name="type_id" id="type_id" value="{$type_id}">
            <div class="layui-form-item">
                <label class="layui-form-label required">标题</label>
                <div class="layui-input-block">
                    <input type="text" id="title" name="title" value="{$data.title}" lay-verify="required"
                           autocomplete="off"
                           class="layui-input" lay-reqtext="标题不能为空">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">时间</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="range_time" name="range_time"  value="{$data.range_time}" placeholder="开始时间 至 结束时间">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">点击量</label>
                    <div class="layui-input-inline">
                        <input type="number" id="click" name="click" value="{$data.click}" autocomplete="off"
                               class="layui-input">
                        <tip>默认随机100以内</tip>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">权重</label>
                    <div class="layui-input-inline">
                        <input type="number" id="weight" name="weight" value="{$data.weight}" autocomplete="off"
                               class="layui-input">
                        <tip>越小排序越靠前</tip>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">来源</label>
                    <div class="layui-input-inline">
                        <input type="text" id="nickname" name="nickname"
                               value="{$data.nickname}"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">PDF文件</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline" style="width: 50%">
                        <input type="text" name="file_url" id="file_url" value="{$data.file_url}"
                               onmouseover="hui_img_preview('image-select-input',this.value)"
                               onmouseout="layer.closeAll();" id="image-select-input" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:30px;line-height: 37px;">
                        <a href="{$data.file_url}" target="_blank">查看</a>
                    </div>
                    <div class="layui-input-inline" style="width: 120px">
                        <button type="button" class="layui-btn" id="pdf_file_url">
                        <i class="layui-icon">&#xe67c;</i>选择PDF文件
                        </button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">内容</label>
                {if($editor eq 1)}
                <div class="layui-input-block" id="contentEditorHtml" style="z-index: 0">
                    {php}echo lib\Form::editor('content',$val=$data['content'], 'width:100%;height:400px');{/php}
                </div>
                {else}
                <div class="layui-input-block" id="contentEditorMD">
                    {php}echo lib\Form::editorMd('content',$val=$data['content']);{/php}
                </div>
                {/if}
            </div>

            <div class="layui-form-item layui-hide">
                <label class="layui-form-label required">状态</label>
                <div class="layui-input-block">
                    <input type="hidden" name="id" value="{$data.id}">
                    <input type="hidden" name="editor" value="{$editor}">
                    <input type="hidden" name="status" value="{$data.status}">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm" onclick="set_status(1)">立即提交
                    </button>
                    <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="set_status(0)"> 保存草稿
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
{include file='footer'/}
<script>
  layui.use(['form','laydate','upload', 'jquery'], function () {
    let form = layui.form, laydate = layui.laydate, $ = layui.jquery, upload = layui.upload;
    form.render();

    upload.render({
        elem: '#pdf_file_url'
        , url: "{:__url('upload/index',['save_path'=>'PDF'])}"
        ,accept: 'file'
        ,exts: 'pdf'
        , done: function (res) {
            if (res.code === 1) {
                $("#file_url").val(res.url);
            }
        }
    })
    laydate.render({
      elem: '#range_time'
      ,type: 'date'
      ,range: '至'
      ,format: 'yyyy-M-d'
    });
    form.render();
    window.dosub = function (obj) {
      HuiDoSub($(obj).serialize(), "{:__url('content.Article/edit')}");
    }
  })
  ;
</script>

</body>
</html>
